package cn.swu.vxhomework2

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import kotlin.math.log

lateinit var manager: FragmentManager
val TAG = "@@laile"
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
//        manager=supportFragmentManager
//
//        val transaction=manager.beginTransaction()
//       // transaction.replace(R.id.rightlayout,fragment)
//     //   transaction.add(R.id.mainfragment,)
//        transaction.commit();
       // initview()
        val btnchat=findViewById<Button>(R.id.chat)
        val btnpeople=findViewById<Button>(R.id.relation)
        val btnpyq=findViewById<Button>(R.id.pyq)
        val btnme=findViewById<Button>(R.id.me)


        btnchat.setOnClickListener()
        {
            Log.d(TAG,"chat")
            replacefragment(chat())
        }
        btnpeople.setOnClickListener()
        {
            Log.d(TAG,"people")
            replacefragment(peopleFragment())
        }
        btnpyq.setOnClickListener()
        {
            Log.d(TAG,"pyq")
            replacefragment(pyqFragment())
        }
        btnme.setOnClickListener()
        {
            Log.d(TAG,"me")
            replacefragment(meFragment())
        }
    }

    private fun replacefragment(fragment:Fragment)
    {
        val fragmentManager=supportFragmentManager
        val transaction=fragmentManager.beginTransaction()
        transaction.replace(R.id.bigfragment,fragment)
        transaction.commit()
    }
    //  view.findViewById<Button>(R.id.btn_life).setOnClickListener(this)
   // view.findViewById<Button>(R.id.btn_work).setOnClickListener(this)

    private fun initview() {
        TODO("Not yet implemented")
    }


}